package com.lu.project.config;


import com.lu.project.interceptors.LoginInterceptor;
import com.lu.project.interceptors.UserTokenIntercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Resource
    private UserTokenIntercept userTokenIntercept;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录接口和注册接口不拦截
        registry.addInterceptor(userTokenIntercept)
                .excludePathPatterns(
                        "/user/login","/user/register",
                        "/ws/**",
                        "/swagger-ui.html",
                        "/webjars/**",
                        "/swagger-resources",
                        "/v3/api-docs","/api/doc.html",
                        "/ws/**"

                )
                .order(1)
                .addPathPatterns("/**"); // 此配置会拦截所有请求

    }
}
